

## 0 up, 1 down, 2 left, 3 right

import numpy as np
import math

def player1(boardSet):
    N = math.sqrt(len(boardSet[0]))
    for i in range(2):
        if boardSet[1][i][3] == 1:
            player = boardSet[1][i]
    while True:
       s = np.random.randint(0,4)
       print(s)

       if s == 0 and player[1] < N and boardSet[0][(player[0],player[1]+1)][0]!=2:
           return s
       elif s == 1 and player[1] > 1 and boardSet[0][(player[0],player[1]-1)][0]!=2:
           return s
       elif s == 2 and player[0] > 1 and boardSet[0][(player[0]-1, player[1])][0] != 2:
           return s
       elif s == 3 and player[0] < N and boardSet[0][(player[0] + 1, player[1])][0] != 2:
           return s


def player2(boardSet):
    N = math.sqrt(len(boardSet[0]))
    for i in range(2):
        if boardSet[1][i][3] == 2:
            player = boardSet[1][i]
    while True:
        s = np.random.randint(0, 4)
        if s == 0 and player[1] < N and boardSet[0][(player[0], player[1] + 1)][0] != 2:
            return s
        elif s == 1 and player[1] > 1 and boardSet[0][(player[0], player[1] - 1)][0] != 2:
            return s
        elif s == 2 and player[0] > 1 and boardSet[0][(player[0] - 1, player[1])][0] != 2:
            return s
        elif s == 3 and player[0] < N and boardSet[0][(player[0] + 1, player[1])][0] != 2:
            return s